from rest_framework.serializers import ModelSerializer

from courses import models


class TeacherSerializer(ModelSerializer):
    """
    Serializer for the Teacher model.
    """
    class Meta:
        model = models.Teacher
        fields = "__all__"


class CourseSerializer(ModelSerializer):
    class Meta:
        model = models.Course
        fields = "__all__"


class CourseLessonSerializer(ModelSerializer):
    class Meta:
        model = models.CourseLesson
        fields = "__all__"


class CourseChapterSerializer(ModelSerializer):
    lessons = CourseLessonSerializer(many=True)

    class Meta:
        model = models.CourseChapter
        fields = "__all__"


class CourseDetailSerializer(ModelSerializer):
    teacher = TeacherSerializer()
    chapters = CourseChapterSerializer(many=True)

    class Meta:
        model = models.Course
        fields = "__all__"
